﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Arbalest.Web.Helpers;
using System.Data.SqlClient;
using System.Data;

namespace Arbalest.Web.Controllers
{
    public class SiteController : Controller
    {
        //
        // GET: /Site/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Search()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Search(string searchTerm)
        {
            @ViewBag.SearchMessage = string.Format("Search results for {0}", searchTerm);

            DataSet ds = DataHelper.SqlServer.RESEARCH_PROD_CORE.FetchDataSet(
                "workdb.dbo.SPrvwGetSecurityList",
                new SqlParameter("@searchString", searchTerm));

            DataTable resultDataTable = null;

            if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                resultDataTable = ds.Tables[0];
            
            return View(resultDataTable);
        }
    }
}
